home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio 2000 #1
/
Ham Radio 2000.iso
/
ham2000
/
hf
/
dsp
/
leonid
/
boot.lst
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
File List
|
1994-03-25
|
89.7 KB
|
1,976 lines
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 1
1 page 132,79
2 opt rc
4
5 ;***************************************************************
6 ;* BOOT.ASM -- DSP56001 interrupt vector table and DSP CARD 4 *
7 ;* initialization, self cheking and communication *
8 ;* service routines *
9 ;* *
10 ;* Here are all DSP56001 interrupt vectors and space for *
11 ;* interrupt contexts and basic interrupt service routines. *
12 ;* Also included are initalization code, self checking and *
13 ;* support routines for host communication, codec control, *
14 ;* low level AX25 handling and transmit control. *
15 ;* *
16 ;* KISS protocol handling is based on article *
17 ;* Chepponis, M., Karn, P.: *
18 ;* "The KISS TNC: A simple Host-to-TNC communications *
19 ;* protocol", *
20 ;* Proc. of the sixth ARRL computer networking cnf., 1988 *
21 ;* *
22 ;* HDLC protocol handling is based on article *
23 ;* Carlson, D., E.: *
24 ;* "Bit-Oriented Data Link Control Procedures", *
25 ;* IEEE Trans. on Comm., Vol. 28, No. 4, April 1980 *
26 ;* *
27 ;* CRC calculation/checking is based on article *
28 ;* Morse, G.: *
29 ;* "Calculating CRCs by bits and bytes", *
30 ;* BYTE Vol. 11, No. 9, September 1986 *
31 ;* *
32 ;* Copyright (C) 1992-1994 by Alef Null. All rights reserved. *
33 ;* Author(s): Jarkko Vuori, OH2LNS *
34 ;* Modification(s): *
35 ;***************************************************************
36
37 ; DSP CARD specific parameters
38 000001 xtal equ 27000000 ; XTAL frq (in MHz)
9BFCC0
39 001400 topmem equ $1400 ; top p memory locations where buffers and monitor routines are located
40 008000 rom equ $8000 ; starting address of the EPROM
41 00C600 monhigh equ $c600 ; part of monitor to be placed on high memory
42 008000 romlen equ 32768 ; lenght of the EPROM (in bytes)
43
44 000100 ramx equ $0100 ; external X RAM st address
45 001F00 ramxlen equ $2000-$0100 ; external X RAM lenght
46 000100 ramy equ $0100 ; external Y RAM st address
47 003F00 ramylen equ $4000-$0100 ; external Y RAM lenght
48 000200 ramp equ $0200 ; external P RAM st address
49 001E00 ramplen equ $2000-$0200 ; external P RAM lenght
50
51
52 ; SCI parameters
53 002580 baud equ 9600 ; SCI baud rate
54 000400 buflen equ 1024 ; SCI input/output buffer lenght
55
56 ; Protocol parameters
57 000000 pgm_flash equ 0 ; commands
58 000001 chg_pgm equ 1
59 000002 read_flash equ 2
60 000003 load_go equ 3
61
62 000004 ack equ 4 ; responses
63 000005 bad_crc equ 5
64 000006 no_flash equ 6
65 000007 erase_err equ 7
66 000008 pgm_err equ 8
67 000009 no_pgm equ 9
68
69 000000 dataorp equ 0 ; download space flags
70 000001 xory equ 1
71
72 002AD4 magicw equ 10964 ; special magic word to detect first time reset
73
74 ; KISS special characters
75 0000C0 fend equ $c0
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 2
DSP CARD 4 Bootloader
76 0000DB fesc equ $db
77 0000DC tfend equ $dc
78 0000DD tfesc equ $dd
79
80 ; HDLC equations
81 0000FF flagmsk equ $ff ; left justified flag mask
82 00007E flag equ %01111110 ; HDLC bit flag
83 0000FE abrtmsk equ $fe ; left justified abort mask
84 0000FE abort equ %11111110 ; abort sequence
85 0000FE fivemsk equ $fe ; left justified five bit mask
86 00007C five equ %01111100 ; left justified five bit sequence
87 008408 poly equ $8408 ; HDLC CRC polynomial (x^16 + x^12 + x^5 + 1)
88 00F0B8 crcchk equ $f0b8 ; special CRC checkword
89
90 ; flags
91 000000 rempty equ 0 ; SCI flags
92 000001 rfull equ 1
93 000002 xempty equ 2
94 000003 xfull equ 3
95 000004 timer equ 4 ; timer flag
96 000005 scmode equ 5 ; serial communication mode
97 000006 xkissf equ 6 ; put KISS frame begin
98 000007 ztstflg equ 7 ; HDLC xmitter status flags
99 000008 zinsflg equ 8
100 000009 hunt equ 9 ; HDLC receiver status flags
101 00000A firstb equ 10
102 00000B scndb equ 11
103 00000C pwrup equ 12 ; set if power-up reset
104 00000D carrier equ 13 ; carrier on/off
105 00000E givedat equ 14 ; data output gate
106
107
108 ; macro for green LED handling
109 copled macro mode
110 m b\mode #14,x:m_pbd
111 m endm
112
113 ; macro for red LED handling
114 cmdled macro mode
115 m b\mode #13,x:m_pbd
116 m endm
117
118 ; macro for immediate move
119 movi macro data,dest
120 m move data,a1
121 m move a1,dest
122 m endm
123
124 ; macro for entering interrupt service routine
125 ; stores x0,x1 and a registers
126 enter macro contex
127 m move x,l:<contex+0
128 m move a10,l:<contex+1
129 m endm
130
131 ; macro for leaving interrupt service routine
132 ; restores x0,x1 and a registers
133 leave macro contex
134 m move l:<contex+0,x
135 m move l:<contex+1,a10
136 m rti
137 m endm
138
139 ; CRC calculation routine
140 ; data in the LSB of a
141 crc macro rem
142 m move #>1,x0
143 m and x0,a rem,x0
144 m eor x0,a
145 m lsr a #>poly,x0
146 m jcc _crc1
147 m eor x0,a
148 m _crc1 move a1,rem
149 m endm
150
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 3
DSP CARD 4 Bootloader
151 ; byte CRC calculation routine
152 ; byte in x0, result in x:<crcrem
153 crcbyte macro
154 m move x0,b1
155 m move #>$000001,x1
156 m move #>poly,y1
157 m do #8,_crc2
158 m
159 m move b1,a1 ; first LSB to remainder
160 m and x1,a x:<crcrem,y0
161 m eor y0,a
162 m
163 m lsr a ; XOR if needed
164 m jcc _crc1
165 m eor y1,a
166 m _crc1 lsr b a1,x:<crcrem
167 m _crc2
168 m endm
169
170 ; macro for subroutines to read word from ROM and load one ROM image
171 romhdlr macro rdromb,rdromw,romload
172 m ; read one byte from the boot ROM to x0
173 m rdromb movep #$00f0,x:m_bcr ; slow EPROM on P bank
174 m move p:(r1)+,x0
175 m move #$0000ff,b1 ; mask unused databits off
176 m and x0,b
177 m move b1,x0
178 m movep #$0000,x:m_bcr ; no more slow EPROM reads
179 m rts
180 m
181 m ; read one word from the boot ROM to a1
182 m rdromw jsr rdromb ; LS byte
183 m move x0,y:<tmp
184 m jsr rdromb ; MS byte
185 m move #>@cvi(@pow(2,8-1)),x1
186 m mpy x0,x1,a y:<tmp,x0
187 m move a0,a1
188 m or x0,a
189 m rts
190 m
191 m ; load memory blocks from r1
192 m romload jsr rdromb ; packet id
193 m move x0,y:<mspace
194 m
195 m jsr rdromw ; address
196 m move a1,r0
197 m
198 m jsr rdromw ; len
199 m move a1,n0
200 m
201 m jeq _loaded
202 m do n0,_contld ; fetch data
203 m jsr rdromb
204 m move x0,y:<tmp
205 m jsr rdromb
206 m move #>@cvi(@pow(2,8-1)),x1
207 m mpy x0,x1,a y:<tmp,x1
208 m move a0,a1
209 m or x1,a
210 m move a1,y:<tmp
211 m jsr rdromb
212 m move #>@cvi(@pow(2,16-1)),x1
213 m mpy x0,x1,a y:<tmp,x1
214 m move a0,a1
215 m or x1,a
216 m jclr #dataorp,y:mspace,_d
217 m move a1,p:(r0)+ ; put to P space
218 m jmp _a
219 m _d jclr #xory,y:mspace,_x
220 m move a1,y:(r0)+ ; put to Y space
221 m jmp _a
222 m _x move a1,x:(r0)+ ; put to X space
223 m _a nop
224 m _contld
225 m jmp romload
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 4
DSP CARD 4 Bootloader
226 m _loaded rts
227 m endm
228
229
468
469 ; Reset vector
470 P:0000 org p:i_reset
471 P:0000 0AF080 jmp boot
000040
472
473 ; Stack error interrupt
474 P:0002 org p:i_stack
475 P:0002 0AF080 jmp shdown
00003C
476
477 ; Trace interrupt
478 P:0004 org p:i_trace
479 P:0004 0AF080 jmp shdown
00003C
480
481 ; SWI
482 P:0006 org p:i_swi
483 P:0006 0AF080 jmp shdown
00003C
484
485 ; IRQA
486 P:0008 org p:i_irqa
487 P:0008 0AF080 jmp shdown
00003C
488
489 ; IRQB
490 P:000A org p:i_irqb
491 P:000A 0AF080 jmp shdown
00003C
492
493 ; SSI transmitter interrupt
494 ;(because syncronous mode, we can use the same interrupt for both reading and writing)
495 P:0010 org p:i_ssitd
496 P:0010 08DFEF movep y:(r7)+,x:m_tx
497 P:0011 0867AF movep x:m_rx,x:(r7)
498
499 ; SSI transmitter interrupt with errors
500 P:0012 org p:i_ssitde
501 P:0012 0870AE movep x:m_sr,x:m_tx ; clear TUE
00FFEF
502
503 ; SCI receive interrupt
504 P:0014 org p:i_scird
505 P:0014 0BF080 jsr sci_rec
001430
506
507 ; SCI receive interrupt with errors
508 P:0016 org p:i_scirde
509 P:0016 0BF080 jsr sci_rec
001430
510
511 ; SCI transmitter interrupt
512 P:0018 org p:i_scitd
513 P:0018 0BF080 jsr sci_xmt
00141A
514
515 ; SCI timer interrupt
516 P:001C org p:i_scitm
517 P:001C 0BF080 jsr sci_tim
001400
518
519 ; Monitor routine jump table (here because host port is not used)
520 P:0020 org p:i_hstrd
521 P:0020 0AF080 jmp opensci
00151C
522 P:0022 0AF080 jmp putc
00153D
523 P:0024 0AF080 jmp getc
00157F
524 P:0026 0AF080 jmp tstc
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 5
DSP CARD 4 Bootloader
001594
525 P:0028 0AF080 jmp endc
00156E
526 P:002A 0AF080 jmp rejc
00157D
527 P:002C 0AF080 jmp putbit
0015F7
528 P:002E 0AF080 jmp getbit
001596
529 P:0030 0AF080 jmp opencd
001661
530 P:0032 0AF080 jmp closecd
001697
531 P:0034 0AF080 jmp stimer
00165A
532 P:0036 0AF080 jmp putio
00169E
533 P:0038 0AF080 jmp caron
0016C0
534 P:003A 0AF080 jmp caroff
0016AF
535
536 ; System error shutdown
537 P:003C 000087 shdown stop
538
539 ; Illegal instruction interrupt
540 P:003E org p:$003e
541 P:003E 0AF080 jmp >shdown
00003C
542
543 ;****************************
544 ;* Start of the program *
545 ;****************************
546 ; no wait states on external memory
547 P:0040 08F4BE boot movep #$0000,x:m_bcr
000000
548
549 ; initialize SCI
550 P:0042 08F4B0 movep #$2b02,x:m_scr ; 8,n,1
002B02
551 P:0044 08F4B2 movep #(xtal+2*16*baud)/(2*2*16*baud)-1,x:m_sccr ; round baud
00002B
552
553 ; initialize port B
554 P:0046 08F4A0 movep #$0000,x:m_pbc ; port B as general purpose port
000000
555 P:0048 08F4A2 movep #$60ff,x:m_pbddr ; PB0-PB7,PB13 and PB14 as outputs
0060FF
556 P:004A 08F4A4 movep #$0000,x:m_pbd
000000
557
558 ; initialize port C
559 P:004C 08F4A1 movep #$0003,x:m_pcc ; TXD,RXD
000003
560 P:004E 08F4A3 movep #$001c,x:m_pcddr ; SCLK,SC0,SC1 as output
00001C
561 P:0050 08F4A5 movep #$0008,x:m_pcd ; PDN up
000008
562
563 ; initialize data structures
564 P:0052 54F400 move #outbuf,a1 ; SCI queue handling
001C00
565 P:0054 540800 move a1,x:<xhead
566 P:0055 540900 move a1,x:<xtail
567 P:0056 54F400 move #inbuf,a1
001800
568 P:0058 540200 move a1,x:<rhead
569 P:0059 540300 move a1,x:<rtail
570 P:005A 05F423 move #buflen-1,m3
0003FF
571
572 P:005C 73F400 move #@cvi(0.5*baud),n3 ; SCI timer system
0012C0
573 P:005E 200013 clr a
574 P:005F 5E0A00 move a,y:<timchg
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 6
DSP CARD 4 Bootloader
575 P:0060 5E0800 move a,y:<timcnt
576
577 P:0061 2C0500 move #<(1<<rempty)|(1<<xempty),a1
578 P:0062 5C0200 move a1,y:<flags ; buffer empty at first
579
580 P:0063 54F400 move #wakeup,a1
00142C
581 P:0065 540A00 move a1,x:<seqptr
582
583 ; check if power-up reset
584 P:0066 5E8C00 move y:<pgmptr,a ; if active program location
585 P:0067 0603A0 rep #4-1 ; contains a special magic pattern
586 P:0068 200022 asr a ; this is not a power-up reset
587 P:0069 44F422 asr a #>magicw,x0
002AD4
588 P:006B 200043 eor x0,a
589 P:006C 0EA0C5 jeq <chkok
590 P:006D 0A026C bset #pwrup,y:<flags
591
592 ; hit watchdog (because system testing will take a while)
593 copled chg
595
596 ; check the system (ROM)
597 P:006F 61F400 move #rom,r1 ; calculate ROM's CRC sum
008000
598 P:0071 54F400 move #$00ffff,a1
00FFFF
599 P:0073 540B00 move a1,x:<crcrem
600
601 P:0074 60F400 move #romlen,r0
008000
602 P:0076 06D000 do r0,check1
00007A
603 P:0078 0D00FE jsr <rdb
604 P:0079 0D0137 jsr <crcb
605 P:007A 000000 nop
606
607 P:007B 44F400 check1 move #>crcchk,x0 ; check with special checkword
00F0B8
608 P:007D 568B00 move x:<crcrem,a
609 P:007E 200045 cmp x0,a
610 P:007F 0E2155 jne <rombad
611
612 ; check the system (RAM)
613 P:0080 54F400 move #$00ffff,a1 ; initialize test pattern generator
00FFFF
614 P:0082 540B00 move a1,x:<crcrem
615
616 P:0083 61F400 move #ramx,r1 ; write test pattern to X ram
000100
617 P:0085 60F400 move #ramxlen,r0
001F00
618 P:0087 06D000 do r0,check2a
00008B
619 P:0089 240000 move #0,x0
620 P:008A 0D0147 jsr <tstpat
621 P:008B 545900 move a1,x:(r1)+
622 check2a
623
624 P:008C 61F400 move #ramy,r1 ; write test pattern to Y ram
000100
625 P:008E 60F400 move #ramylen,r0
003F00
626 P:0090 06D000 do r0,check2b
000094
627 P:0092 240000 move #0,x0
628 P:0093 0D0147 jsr <tstpat
629 P:0094 5C5900 move a1,y:(r1)+
630 check2b
631
632 P:0095 61F400 move #ramp,r1 ; write test pattern to P ram
000200
633 P:0097 60F400 move #ramplen,r0
001E00
634 P:0099 06D000 do r0,check2c
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 7
DSP CARD 4 Bootloader
00009D
635 P:009B 240000 move #0,x0
636 P:009C 0D0147 jsr <tstpat
637 P:009D 07598C move a1,p:(r1)+
638 check2c
639
640 P:009E 54F400 move #$00ffff,a1 ; initialize test pattern generator
00FFFF
641 P:00A0 540B00 move a1,x:<crcrem
642
643 P:00A1 61F400 move #ramx,r1 ; test X ram
000100
644 P:00A3 60F400 move #ramxlen,r0
001F00
645 P:00A5 240000 move #0,x0
646 P:00A6 06D000 do r0,check3a
0000AC
647 P:00A8 0D0147 jsr <tstpat
648 P:00A9 44D900 move x:(r1)+,x0
649 P:00AA 240043 eor x0,a #0,x0
650 P:00AB 0E2159 jne <rambad
651 P:00AC 000000 nop
652 check3a
653
654 P:00AD 61F400 move #ramy,r1 ; test Y ram
000100
655 P:00AF 60F400 move #ramylen,r0
003F00
656 P:00B1 240000 move #0,x0
657 P:00B2 06D000 do r0,check3b
0000B8
658 P:00B4 0D0147 jsr <tstpat
659 P:00B5 4CD900 move y:(r1)+,x0
660 P:00B6 240043 eor x0,a #0,x0
661 P:00B7 0E2159 jne <rambad
662 P:00B8 000000 nop
663 check3b
664
665 P:00B9 61F400 move #ramp,r1 ; test P ram
000200
666 P:00BB 60F400 move #ramplen,r0
001E00
667 P:00BD 240000 move #0,x0
668 P:00BE 06D000 do r0,check3c
0000C4
669 P:00C0 0D0147 jsr <tstpat
670 P:00C1 07D984 move p:(r1)+,x0
671 P:00C2 240043 eor x0,a #0,x0
672 P:00C3 0E2159 jne <rambad
673 P:00C4 000000 nop
674 check3c
675
676 ; read the remaining monitor to the upper memory
677 P:00C5 61F400 chkok move #monhigh,r1
00C600
678 P:00C7 0D0110 jsr <memload
679
680 ; start interrupts
681 P:00C8 08F4BF movep #$b000,x:m_ipr ; SSI=IPL2, SCI=IPL1
00B000
682 P:00CA 00FCB8 andi #$fc,mr ; unmask interrupts
683
684 ; wait 1 s for the (possible) command
685 cmdled set
687 P:00CC 44F400 move #>ack,x0 ; tell to host that we managed to get out from the reset
000004
688 P:00CE 0BF080 jsr putc
00153D
689
690 P:00D0 44F400 move #>@cvi(1.0*baud),x0 ; set timer
002580
691 P:00D2 0BF080 jsr stimer
00165A
692 P:00D4 000086 _wchr wait
693 P:00D5 0BF080 jsr getc ; wait for chr of timer
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 8
DSP CARD 4 Bootloader
00157F
694 P:00D7 0E00F8 jcc <cmdok
695 P:00D8 0A02E4 jset #timer,y:<flags,_wchr
0000D4
696
697 ldpgm cmdled clr ; no complete command, turn cmd led off
699 P:00DB 5E8C00 move y:<pgmptr,a
700 P:00DC 0A02EC jset #pwrup,y:<flags,firstrs
0000F2
701
702 P:00DE 44F400 _nopgm move #>$00000f,x0 ; no, calculate next pgm slot number
00000F
703 P:00E0 44F446 and x0,a #>1,x0
000001
704 P:00E2 45F440 add x0,a #>16,x1 ; robin round if last pgm slot number
000010
705 P:00E4 200065 cmp x1,a
706 P:00E5 021040 tge x0,a
707 P:00E6 5C0C00 move a1,y:<pgmptr
708 P:00E7 0BF080 jsr ldadr
001740
709 P:00E9 5E8C00 move y:<pgmptr,a
710 P:00EA 0EA0DE jeq <_nopgm
711 P:00EB 57F400 ldnextp move #>magicw<<4,b ; active pgm slot found, store slot number
02AD40
712 P:00ED 218400 move a1,x0
713 P:00EE 20004A or x0,b
714 P:00EF 5D0C00 move b1,y:<pgmptr
715 P:00F0 0AF080 jmp lromg ; and load image from ROM and jump to it
001516
716
717 P:00F2 61F400 firstrs move #rom+2,r1 ; first reset, check if there are autoboot programs
008002
718 P:00F4 0D0107 jsr <rdw
719 P:00F5 0E20EB jne <ldnextp
720
721 P:00F6 000086 _idling wait ; nothing to do (no command given, no program to load from ROM)
722 P:00F7 0C00F6 jmp <_idling
723
724 ; command read, search command
725 P:00F8 56F400 cmdok move #>load_go,a
000003
726 P:00FA 200045 cmp x0,a
727 P:00FB 0AF0AA jeq lg
0014C4
728
729 P:00FD 0C00DA jmp <ldpgm
730
731
732 ; temporary utility routines in internal memory
733 romhdlr rdb,rdw,memload
789
790 crcb crcbyte
805 P:0146 00000C rts
806
807 ; pseudonoise RAM test pattern generator (pattern in a)
808 P:0147 0D0137 tstpat jsr <crcb
809 P:0148 568B00 move x:<crcrem,a
810 P:0149 0607A0 rep #8-1
811 P:014A 200033 lsl a
812 P:014B 458B33 lsl a x:<crcrem,x1
813 P:014C 200063 eor x1,a
814 P:014D 00000C rts
815
816 ; 100 ms software delay
817 P:014E 06C785 dly100 do #@cvi(@sqt(xtal/2.0/10.0)),_romb2
000153
818 P:0150 06C785 do #@cvi(@sqt(xtal/2.0/10.0)),_romb1
000152
819 P:0152 000000 nop
820 P:0153 000000 _romb1 nop
821 P:0154 00000C _romb2 rts
822
823 ; show that ROM has failed crc check (red and green led blinks at 10 Hz)
824 P:0155 0D014E rombad jsr <dly100
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 9
DSP CARD 4 Bootloader
825 copled chg
827 cmdled chg
829 P:0158 0C0155 jmp <rombad
830
831 ; show that RAM has failed check (greed led blinks at 10 Hz, red led blinks at 5 Hz)
832 P:0159 0D014E rambad jsr <dly100
833 copled chg
835 cmdled chg
837 P:015C 0D014E jsr <dly100
838 copled chg
840 P:015E 0C0159 jmp <rambad
841
842
843
844 ;**********************************************************
845 ;* The following code will be placed to top p-memory bank *
846 ;**********************************************************
847
848 P:1400 org p:topmem
849
850 ;****************************
851 ;* SCI timer interrupt *
852 ;****************************
853 sci_tim enter scidata ; only a1,a0,x1,x0 are saved
856
857 ; increment timer
858 P:1402 05F423 move #-1,m3 ; yes, set next time
FFFFFF
859 P:1404 6B8800 move y:<timcnt,r3
860
861 ; check if destination time reached
862 P:1405 5C8900 move y:<timval,a1
863 P:1406 226400 move r3,x0
864 P:1407 205B43 eor x0,a (r3)+
865 P:1408 0AF0A2 jne _scit1
00140B
866 P:140A 0A0244 bclr #timer,y:<flags ; yes, clear flag bit
867
868 ; check if watch-dog interval reached
869 P:140B 5C8A00 _scit1 move y:<timchg,a1
870 P:140C 6B0843 eor x0,a r3,y:<timcnt
871 P:140D 0AF0A2 jne scite
001413
872 copled chg
874 P:1410 204B00 move (r3)+n3
875 P:1411 000000 nop
876 P:1412 6B0A00 move r3,y:<timchg
877
878 P:1413 0BF080 scite jsr pertick ; xmit control module timer
0016E7
879 P:1415 05F423 move #buflen-1,m3
0003FF
880 leave scidata
884
885
886
887 ;****************************
888 ;* SCI xmit interrupt *
889 ;****************************
890 sci_xmt enter scidata ; only a1,a0,x1,x0 are saved
893
894 P:141C 638900 move x:<xtail,r3
895 P:141D 448800 move x:<xhead,x0
896 P:141E 08DB74 movep p:(r3)+,x:m_stxl
897 P:141F 630900 move r3,x:<xtail
898
899 P:1420 0A0243 bclr #xfull,y:<flags ; don't bother to check buffer state if it is full
900 P:1421 0AF0A8 jcs scixe
001429
901
902 ; check if buffer empty
903 P:1423 226C00 move r3,a1
904 P:1424 200043 eor x0,a
905 P:1425 0AF0A2 jne scixe
001429
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 10
DSP CARD 4 Bootloader
906
907 ; yes, shut down xmitter
908 P:1427 0A0262 bset #xempty,y:<flags
909 P:1428 0AB00C bclr #m_tie,x:m_scr
910
911 scixe leave scidata
915
916
917 ;****************************
918 ;* SCI receive interrupt *
919 ;****************************
920 P:142C wakeup dc $12,$b9,$b0,$a1
921 sci_rec enter scidata ; only a1,a0,x1,x0 are saved
924
925 P:1432 084531 movep x:m_ssr,x1 ; clear SCI errors
926
927 ; first check for special wake-up sequence
928 P:1433 638A00 move x:<seqptr,r3
929 P:1434 084534 movep x:m_srxl,x1 ; read byte to x1
930 P:1435 07DB8C move p:(r3)+,a1
931 P:1436 44F463 eor x1,a #>wakeup+4,x0
001430
932 P:1438 0AF0AA jeq scir1
00143E
933 P:143A 63F400 move #wakeup,r3
00142C
934 P:143C 0AF080 jmp scir2
001443
935 P:143E 226C00 scir1 move r3,a1
936 P:143F 200043 eor x0,a
937 P:1440 0AF0A2 jne scir2
001443
938
939 ; wake-up sequence detected (boot the system up)
940 P:1442 000087 stop ; watchdog will give reset pulse
941
942 ; no wake-up sequence detected, continue searching
943 P:1443 630A00 scir2 move r3,x:<seqptr
944
945 ; then check that there are room left in the buffer
946 P:1444 0A02E1 jset #rfull,y:<flags,scire
0014C1
947
948 ; yes, determine in which mode we are (normal, KISS mode)
949 P:1446 0A02E5 jset #scmode,y:<flags,scir3
001454
950
951 ; * normal mode, put data to buffer
952 P:1448 638200 move x:<rhead,r3
953 P:1449 0A0240 bclr #rempty,y:<flags
954 P:144A 075B85 move x1,p:(r3)+
955 P:144B 630200 move r3,x:<rhead
956
957 ; check buffer full condition
958 P:144C 226C00 move r3,a1
959 P:144D 448300 move x:<rtail,x0
960 P:144E 200043 eor x0,a
961 P:144F 0AF0A2 jne scire
0014C1
962 P:1451 0A0261 bset #rfull,y:<flags
963
964 P:1452 0AF080 jmp scire
0014C1
965
966 ; * KISS protocol mode, read received character
967 P:1454 638C00 scir3 move x:<getkst,r3
968 P:1455 2CC000 move #fend,a1
969 P:1456 0AE380 jmp (r3) ; determine what to do for it
970
971 ; --- State 0, waiting for FEND
972 P:1457 44F463 str0 eor x1,a #>str1,x0
00145E
973 P:1459 0AF0A2 jne scire ; we didn't see FEND, keep looking
0014C1
974 P:145B 440C00 move x0,x:<getkst ; FEND found, change state
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 11
DSP CARD 4 Bootloader
975 P:145C 0AF080 jmp scire
0014C1
976
977 ; --- State 1, we have seen FEND, look for the command byte
978 P:145E 44F463 str1 eor x1,a #>str2,x0
001470
979 P:1460 0AF0AA jeq scire ; just another FEND, keep looking for cmd
0014C1
980 ; analyze command byte
981 P:1462 2C0000 move #0,a1
982 P:1463 450F63 eor x1,a x1,x:<kisscmd
983 P:1464 0AF0AA jeq str1b ; cmd 0, data will follow
00146B
984 ; store cmd and change state
985 P:1466 54F400 str1a move #str4,a1
0014AB
986 P:1468 540C00 move a1,x:<getkst
987 P:1469 0AF080 jmp scire
0014C1
988 ; start a new frame
989 P:146B 440C00 str1b move x0,x:<getkst
990 P:146C 548200 move x:<rhead,a1 ; get current rhead
991 P:146D 540D00 move a1,x:<rnhead
992 P:146E 0AF080 jmp scire
0014C1
993
994 ; --- State 2, data to follow
995 P:1470 200063 str2 eor x1,a ; check if end of frame
996 P:1471 0AF0AA jeq strend
00147C
997 P:1473 2CDB00 move #fesc,a1
998 P:1474 200063 eor x1,a ; check if escape
999 P:1475 0AF0A2 jne store
001499
1000 ; escape character found
1001 P:1477 54F400 move #str3,a1 ; enter FESC found state
001480
1002 P:1479 540C00 move a1,x:<getkst
1003 P:147A 0AF080 jmp scire
0014C1
1004 ; end of frame, store negative value
1005 P:147C 45F400 strend move #-1,x1
FFFFFF
1006 P:147E 0AF080 jmp store
001499
1007
1008 ; --- State 3, saw FESC, expecting TFESC or TFEND
1009 P:1480 2CDD00 str3 move #tfesc,a1 ; check if TFESC
1010 P:1481 200063 eor x1,a
1011 P:1482 0AF0AA jeq str3esc
00148D
1012 P:1484 2CDC00 move #tfend,a1
1013 P:1485 200063 eor x1,a ; check if TFEND
1014 P:1486 0AF0AA jeq str3end
001494
1015 P:1488 54F400 move #str2,a1
001470
1016 P:148A 540C00 move a1,x:<getkst ; something wrong has happened,
1017 P:148B 0AF080 jmp scire ; go back to the data receiving mode
0014C1
1018 ; we have seen TFESC after an FESC, write an FESC
1019 P:148D 54F400 str3esc move #str2,a1
001470
1020 P:148F 540C00 move a1,x:<getkst
1021 P:1490 45F400 move #>fesc,x1
0000DB
1022 P:1492 0AF080 jmp store
001499
1023 ; we have seen TFEND after an FESC, write an FEND
1024 P:1494 54F400 str3end move #str2,a1
001470
1025 P:1496 540C00 move a1,x:<getkst
1026 P:1497 45F400 move #>fend,x1
0000C0
1027
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 12
DSP CARD 4 Bootloader
1028 ; store the character to the queue
1029 P:1499 638D00 store move x:<rnhead,r3
1030 P:149A 448300 move x:<rtail,x0
1031 P:149B 075B85 move x1,p:(r3)+
1032 P:149C 226C00 move r3,a1 ; check buffer full
1033 P:149D 630D43 eor x0,a r3,x:<rnhead
1034 P:149E 0AF0AA jeq scr_st0 ; queue full, discard current frame
0014BE
1035 ; check if end of frame
1036 P:14A0 54F400 move #-1,a1
FFFFFF
1037 P:14A2 458D63 eor x1,a x:<rnhead,x1
1038 P:14A3 0AF0A2 jne scire
0014C1
1039
1040 P:14A5 450200 move x1,x:<rhead ; yes, reset real buffer write pointer
1041 P:14A6 0A0240 bclr #rempty,y:<flags
1042 P:14A7 0BF080 jsr frmrec ; inform xmit control module
0016C2
1043 P:14A9 0AF080 jmp scr_st0
0014BE
1044
1045 ; --- State 4, get command data
1046 P:14AB 580300 str4 move a0,y:<tmp ; backup a0
1047 P:14AC 568F00 move x:<kisscmd,a ; check if local parameter
1048 P:14AD 44F400 move #>kisses,x0
000005
1049 P:14AF 44F445 cmp x0,a #>kisspar-1,x0
0016A9
1050 P:14B1 0AF0A7 jgt str4a
0014BA
1051
1052 P:14B3 44F440 add x0,a #>baud/100,x0
000060
1053 P:14B5 21D3A0 mpy x0,x1,a a,r3 ; yes, time scale parameter
1054 P:14B6 200022 asr a ; interger multiply correction
1055 P:14B7 076388 move a0,p:(r3) ; product in low order word
1056 P:14B8 0AF080 jmp str4b
0014BD
1057
1058 P:14BA 6B8E00 str4a move y:<kisssub,r3 ; no, give it to the user application
1059 P:14BB 568F00 move x:<kisscmd,a
1060 P:14BC 0BE380 jsr (r3) ; a1 - cmd, x1 - data
1061 P:14BD 588300 str4b move y:<tmp,a0
1062
1063 ; go back to FEND hunt state
1064 P:14BE 54F400 scr_st0 move #str0,a1
001457
1065 P:14C0 540C00 move a1,x:<getkst
1066
1067 scire leave scidata
1071
1072
1073 ;**************************
1074 ;* LOAD FROM HOST AND GO *
1075 ;**************************
1076 P:14C4 44F400 lg move #>ack,x0 ; tell to host that command was accepted
000004
1077 P:14C6 0BF080 jsr putc
00153D
1078
1079 P:14C8 54F400 lghunt move #$00ffff,a1 ; try to find beginning of the frame
00FFFF
1080 P:14CA 540B00 move a1,x:<crcrem
1081 P:14CB 0BF080 jsr rdbyte
00170C
1082 P:14CD 56F400 move #>flag,a
00007E
1083 P:14CF 200045 cmp x0,a
1084 P:14D0 0AF0A2 jne lghunt
0014C8
1085
1086 P:14D2 0BF080 jsr rdbyte ; packet id
00170C
1087 P:14D4 4C0B00 move x0,y:<mspace
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 13
DSP CARD 4 Bootloader
1088
1089 P:14D5 0BF080 jsr rdword ; address
001701
1090 P:14D7 219000 move a1,r0
1091
1092 P:14D8 0BF080 jsr rdword ; len
001701
1093 P:14DA 219800 move a1,n0
1094
1095 P:14DB 0AF0AA jeq alldata
0014FD
1096 P:14DD 06D800 do n0,alldata ; fetch data
0014FC
1097 P:14DF 0BF080 jsr rdbyte
00170C
1098 P:14E1 45F400 move #>@cvi(@pow(2,16-1)),x1
008000
1099 P:14E3 2000A0 mpy x0,x1,a
1100 P:14E4 580300 move a0,y:<tmp
1101 P:14E5 0BF080 jsr rdbyte
00170C
1102 P:14E7 45F400 move #>@cvi(@pow(2,8-1)),x1
000080
1103 P:14E9 4D83A0 mpy x0,x1,a y:<tmp,x1
1104 P:14EA 210C00 move a0,a1
1105 P:14EB 200062 or x1,a
1106 P:14EC 5C0300 move a1,y:<tmp
1107 P:14ED 0BF080 jsr rdbyte
00170C
1108 P:14EF 5E8300 move y:<tmp,a
1109 P:14F0 200042 or x0,a
1110 P:14F1 0A0BC0 jclr #dataorp,y:mspace,_d
0014F6
1111 P:14F3 07588C move a1,p:(r0)+ ; put to P space
1112 P:14F4 0AF080 jmp _a
0014FC
1113 P:14F6 0A0BC1 _d jclr #xory,y:mspace,_x
0014FB
1114 P:14F8 5C5800 move a1,y:(r0)+ ; put to Y space
1115 P:14F9 0AF080 jmp _a
0014FC
1116 P:14FB 545800 _x move a1,x:(r0)+ ; put to X space
1117 P:14FC 000000 _a nop
1118 alldata
1119
1120 P:14FD 0BF080 jsr rdbyte ; CRC
00170C
1121 P:14FF 0BF080 jsr rdbyte
00170C
1122 P:1501 44F400 move #>crcchk,x0
00F0B8
1123 P:1503 568B00 move x:<crcrem,a
1124 P:1504 44F445 cmp x0,a #>ack,x0
000004
1125 P:1506 0AF0AA jeq _crcok
00150E
1126 P:1508 44F400 move #>bad_crc,x0 ; crc bad, ignore frame
000005
1127 P:150A 0BF080 jsr putc
00153D
1128 P:150C 0AF080 jmp lghunt
0014C8
1129
1130 P:150E 0BF080 _crcok jsr putc ; crc ok, if len=0 then jump to the user code
00153D
1131 P:1510 230E00 move n0,a
1132 P:1511 200003 tst a
1133 P:1512 0AF0A2 jne lghunt
0014C8
1134 cmdled clr
1136 P:1515 0C0040 jmp <boot
1137
1138
1139 ;********************
1140 ;* LOAD ROM AND GO *
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 14
DSP CARD 4 Bootloader
1141 ;********************
1142 ; program number is in a1 register
1143 P:1516 0BF080 lromg jsr ldadr
001740
1144 P:1518 219100 move a1,r1
1145 P:1519 0BF080 jsr romload ; then load the program
00175D
1146 P:151B 0C0040 jmp <boot ; and finally jump to it
1147
1148
1149 ;****************************
1150 ;* Open Serial line *
1151 ;****************************
1152 ; flushes all buffers and set the desired communication speed
1153 ; a - kiss command routine address (zero if not is kiss mode)
1154 ; b - xmit on/off routine address
1155 P:151C 5E0E00 opensci move a,y:<kisssub
1156 P:151D 0A0245 bclr #scmode,y:<flags
1157 P:151E 54F403 tst a #str0,a1
001457
1158 P:1520 0AF0AA jeq opensce
00153C
1159
1160 ; KISS mode, initialize handlers
1161 P:1522 5D1400 move b1,y:<xmitsub ; store given addresses
1162 P:1523 540C00 move a1,x:<getkst
1163 P:1524 55F400 move #(1<<xoff),b1
000008
1164 P:1526 55141B clr b b1,x:<pstate ; and initialize xmit control module
1165 P:1527 5D1500 move b1,y:<pertim
1166
1167 P:1528 0A0265 bset #scmode,y:<flags
1168 P:1529 0A0246 bclr #xkissf,y:<flags
1169
1170 movi #xstD,y:<xstate ; initialize coder
1173 movi #flag,y:<xdata
1176 movi #$0,y:<x5bit
1179 movi #0,y:<xbit
1182 P:1533 0A0247 bclr #ztstflg,y:<flags
1183 P:1534 0A0248 bclr #zinsflg,y:<flags
1184
1185 movi #0,x:<rdata ; initialize decoder
1188 movi #$0,x:<rflag
1191 P:1539 0A0269 bset #hunt,y:<flags
1192 P:153A 0A026A bset #firstb,y:<flags
1193 P:153B 0A026B bset #scndb,y:<flags
1194
1195 P:153C 00000C opensce rts
1196
1197
1198 ;****************************
1199 ;* Put character to queue *
1200 ;****************************
1201 ; byte in x0
1202 ; returns Z if buffer full
1203 ; NZ otherwise
1204 P:153D 0002F8 putc ori #$02,mr ; disable interrupts
1205 P:153E 000000 nop
1206 P:153F 000000 nop
1207 P:1540 0A02E5 jset #scmode,y:<flags,putkiss
001553
1208
1209 ; * normal mode
1210 P:1542 458900 move x:<xtail,x1
1211 P:1543 548800 move x:<xhead,a1
1212 P:1544 219300 move a1,r3
1213
1214 ; xmitter was running, check if there are free space left
1215 P:1545 0A0242 bclr #xempty,y:<flags ; if buffer empty, sure there are free space left
1216 P:1546 0AF0A8 jcs putc1
00154E
1217 P:1548 200063 eor x1,a ; if read ptr <> write ptr there are also free space left
1218 P:1549 0AF0A2 jne putc2
00154F
1219
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 15
DSP CARD 4 Bootloader
1220 ; buffer full state reached (ignore given data)
1221 P:154B 0A0263 bset #xfull,y:<flags
1222 P:154C 0AF080 jmp putce
00156C
1223
1224 ; there was free space left, write character to the buffer
1225 P:154E 0AB02C putc1 bset #m_tie,x:m_scr ; start xmitter interrupts
1226 P:154F 075B84 putc2 move x0,p:(r3)+
1227 P:1550 630800 move r3,x:<xhead
1228 P:1551 0AF080 jmp putce
00156C
1229
1230
1231 ; * KISS mode, check if start of new KISS frame
1232 P:1553 0A02E6 putkiss jset #xkissf,y:<flags,putk1
00155D
1233
1234 ; yes, send KISS preamble
1235 P:1555 0A0266 bset #xkissf,y:<flags
1236 P:1556 638800 move x:<xhead,r3
1237 P:1557 630E00 move r3,x:<xnhead
1238
1239 P:1558 2CC000 move #fend,a1
1240 P:1559 075B8C move a1,p:(r3)+
1241 P:155A 2C0000 move #0,a1
1242 P:155B 075B8C move a1,p:(r3)+
1243
1244 P:155C 630E00 move r3,x:<xnhead
1245
1246 ; no, send pure data only
1247 P:155D 638E00 putk1 move x:<xnhead,r3
1248
1249 P:155E 2CDB00 move #fesc,a1 ; check if FESC
1250 P:155F 2DDD43 eor x0,a #tfesc,b1
1251 P:1560 0AF0AA jeq putkspe
001566
1252
1253 P:1562 2CC000 move #fend,a1 ; check if FEND
1254 P:1563 2DDC43 eor x0,a #tfend,b1
1255 P:1564 0AF0A2 jne putke1
00156A
1256
1257 ; special character, enter escaped special character
1258 P:1566 44F400 putkspe move #>fesc,x0
0000DB
1259 P:1568 075B84 move x0,p:(r3)+
1260 P:1569 21A400 move b1,x0
1261
1262 P:156A 075B84 putke1 move x0,p:(r3)+
1263 P:156B 630E00 move r3,x:<xnhead
1264
1265 P:156C 00FCB8 putce andi #$fc,mr
1266 P:156D 00000C rts
1267
1268
1269 ;****************************
1270 ;* End current KISS frame *
1271 ;****************************
1272 P:156E 0002F8 endc ori #$02,mr ; disable interrupts
1273 P:156F 000000 nop
1274 P:1570 000000 nop
1275 P:1571 000000 nop
1276 P:1572 0A0246 bclr #xkissf,y:<flags
1277
1278 P:1573 638E00 move x:<xnhead,r3 ; write last fend
1279 P:1574 44F400 move #>fend,x0
0000C0
1280 P:1576 075B84 move x0,p:(r3)+
1281 P:1577 630800 move r3,x:<xhead
1282
1283 P:1578 0A02C2 jclr #xempty,y:<flags,ekisse ; check for idling xmitter
00157B
1284 P:157A 0AB02C bset #m_tie,x:m_scr
1285
1286 P:157B 00FCB8 ekisse andi #$fc,mr
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 16
DSP CARD 4 Bootloader
1287 P:157C 00000C rts
1288
1289
1290 ;****************************
1291 ;* Reject current KISS frame*
1292 ;****************************
1293 P:157D 0A0246 rejc bclr #xkissf,y:<flags
1294 P:157E 00000C rts
1295
1296
1297 ;****************************
1298 ;* Get character from queue *
1299 ;****************************
1300 ; byte in x0
1301 ; returns C if no data available
1302 ; NC if data available
1303 P:157F 0002F8 getc ori #$02,mr ; disable interrupts
1304 P:1580 000000 nop
1305 P:1581 000000 nop
1306 P:1582 000000 nop
1307 P:1583 000000 nop
1308 P:1584 638300 move x:<rtail,r3
1309
1310 ; check if there are data available
1311 P:1585 0B0260 btst #rempty,y:<flags
1312 P:1586 0AF0A8 jcs getce
001592
1313
1314 ; yes, take it from the queue
1315 P:1588 0A0241 bclr #rfull,y:<flags
1316 P:1589 07DB84 move p:(r3)+,x0
1317 P:158A 630300 move r3,x:<rtail
1318
1319 ; check if buffer gets empty
1320 P:158B 568200 move x:<rhead,a
1321 P:158C 226500 move r3,x1
1322 P:158D 200065 cmp x1,a
1323 P:158E 00FEB9 andi #$fe,ccr ; NC
1324 P:158F 0AF0A2 jne getce
001592
1325
1326 ; yes, set empty flag
1327 P:1591 0A0260 bset #rempty,y:<flags
1328
1329 P:1592 00FCB8 getce andi #$fc,mr
1330 P:1593 00000C rts
1331
1332
1333 ;****************************
1334 ;* Test if chrs available *
1335 ;****************************
1336 ; returns C if no data available
1337 ; NC if data available
1338 P:1594 0B0260 tstc btst #rempty,y:<flags
1339 P:1595 00000C rts
1340
1341
1342 ;****************************
1343 ;* Get a bit *
1344 ;****************************
1345 ; returns next bit to be sent in C
1346 ; returns Z if this is an end of the transmission
1347 ; Note! Interrupts are disabled if end of transmission detected
1348
1349 ; check if we are allowed to send data
1350 P:1596 0A02CE getbit jclr #givedat,y:<flags,xstD2
0015F5
1351
1352 ; check if we must insert a zero
1353 P:1598 0A0248 bclr #zinsflg,y:<flags
1354 P:1599 0AF0A8 jcs getins
0015BD
1355
1356 ; check if there are bits left
1357 P:159B 5E9200 move y:<xbit,a
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 17
DSP CARD 4 Bootloader
1358 P:159C 688F03 tst a y:<xstate,r0
1359 P:159D 000000 nop
1360 P:159E 0AE0AA jeq (r0)
1361
1362 ; five bit sequence detection logic
1363 P:159F 0A02C7 getsft0 jclr #ztstflg,y:<flags,getsft1 ; check if logic enabled
0015AB
1364 P:15A1 5E9000 move y:<xdata,a
1365 P:15A2 200023 lsr a
1366 P:15A3 5E9100 move y:<x5bit,a
1367 P:15A4 44F427 ror a #>$f80000,x0
F80000
1368 P:15A6 200046 and x0,a
1369 P:15A7 5C1145 cmp x0,a a1,y:<x5bit
1370 P:15A8 0AF0A2 jne getsft1
0015AB
1371
1372 ; 11111 detected, insert zero
1373 P:15AA 0A0268 bset #zinsflg,y:<flags
1374
1375 ; calculate CRC
1376 P:15AB 5E9000 getsft1 move y:<xdata,a
1377 crc y:<xcrcrem
1385
1386 ; shift data out (LSB first) and decrement bit counter
1387 P:15B6 689200 move y:<xbit,r0
1388 P:15B7 5E9000 move y:<xdata,a
1389 P:15B8 205023 lsr a (r0)-
1390 P:15B9 681200 move r0,y:<xbit
1391 P:15BA 5C1000 move a1,y:<xdata
1392 P:15BB 00FBB9 andi #$fb,ccr ; NZ
1393 P:15BC 00000C rts
1394
1395 ; insert zero bit
1396 P:15BD 200013 getins clr a ; reset five bit counter
1397 P:15BE 5C1100 move a1,y:<x5bit
1398 P:15BF 00FAB9 andi #$fa,ccr ; NC NZ
1399 P:15C0 00000C rts
1400
1401
1402 ; --- A, after a begin flag
1403 xstA
1404 ; set up data xmission
1405 movi #xstB,y:<xstate
1408 movi #$00ffff,y:<xcrcrem ; init CRC generator
1411 P:15C7 0A0267 bset #ztstflg,y:<flags ; enable 11111 checker
1412
1413 ; --- B, after data byte sent
1414 xstB movi #8,y:<xbit ; init bit counter for the next byte
1417 P:15CA 0BF080 jsr getc ; fetch next byte
00157F
1418 P:15CC 4C1000 move x0,y:<xdata
1419 P:15CD 208E00 move x0,a
1420 P:15CE 200003 tst a
1421 P:15CF 0AF0A3 jpl getsft0
00159F
1422
1423 ; last databyte sent, send CRC
1424 movi #xstC,y:<xstate
1427 movi #16,y:<xbit
1430 P:15D6 5E9300 move y:<xcrcrem,a
1431 P:15D7 200017 not a
1432 P:15D8 5C1000 move a1,y:<xdata
1433 P:15D9 0AF080 jmp getsft0
00159F
1434
1435 ; --- C, after CRC sent
1436 xstC movi #xstD,y:<xstate
1439 movi #flag,y:<xdata
1442 movi #8,y:<xbit
1445 P:15E2 0A0247 bclr #ztstflg,y:<flags ; disable 11111 checker
1446 P:15E3 0AF080 jmp getsft0
00159F
1447
1448 ; --- D, after the last flag sent
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 18
DSP CARD 4 Bootloader
1449 P:15E5 0BF080 xstD jsr tstc
001594
1450 P:15E7 0AF0A8 jcs xstD1
0015F3
1451
1452 ; new data to send, start a new frame
1453 movi #xstA,y:<xstate
1456 movi #flag,y:<xdata
1459 movi #8,y:<xbit
1462 P:15F0 0AF080 jmp getsft0
00159F
1463 P:15F2 00000C rts
1464
1465 ; no new data, return with Z
1466 P:15F3 0BF080 xstD1 jsr rdempty ; inform xmit control module
0016D9
1467 P:15F5 0004F9 xstD2 ori #$04,ccr
1468 P:15F6 00000C rts
1469
1470
1471 ;****************************
1472 ;* Put a bit *
1473 ;****************************
1474 ; put next bit in C to the host transmit queue
1475 P:15F7 569100 putbit move x:<rflag,a
1476 P:15F8 2FFE27 ror a #abrtmsk,b
1477 P:15F9 541100 move a1,x:<rflag
1478 P:15FA 218400 move a1,x0
1479
1480 ; check if abort sequence detected
1481 P:15FB 26FE4E and x0,b #abort,y0
1482 P:15FC 20005B eor y0,b
1483 P:15FD 0AF0AA jeq putb4
001656
1484
1485 ; check if flag detected
1486 P:15FF 2FFF00 move #flagmsk,b
1487 P:1600 267E4E and x0,b #flag,y0
1488 P:1601 2EFE5B eor y0,b #fivemsk,a
1489 P:1602 0AF0AA jeq putb3 ; yes, special handling
001633
1490
1491 ; check if 11111 sequence detected
1492 P:1604 267C46 and x0,a #five,y0
1493 P:1605 208F53 eor y0,a x0,b
1494 P:1606 0AF0AA jeq putb2 ; yes, ignore this bit
001632
1495
1496 ; no special sequence detected, shift data normally
1497 P:1608 0A02E9 jset #hunt,y:<flags,putb2
001632
1498 P:160A 56903B lsl b x:<rdata,a
1499 P:160B 45F427 ror a #>@pow(2,-15),x1
000100
1500 P:160D 541000 move a1,x:<rdata
1501 P:160E 218400 move a1,x0
1502
1503 ; calculate CRC
1504 P:160F 45F4A0 mpy x0,x1,a #>1,x1 ; shift to right 15 bits
000001
1505 crc x:<rcrcrem
1513
1514 ; decrement the bit counter
1515 P:161B 569200 move x:<rbit,a
1516 P:161C 2D0864 sub x1,a #8,b1
1517 P:161D 541200 move a1,x:<rbit
1518 P:161E 0AF0A2 jne putb2
001632
1519
1520 ; 8 bit shifted, init bit counter again
1521 P:1620 551200 move b1,x:<rbit
1522 P:1621 0A024A bclr #firstb,y:<flags
1523 P:1622 0AF0A0 jcc putb1
001628
1524
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 19
DSP CARD 4 Bootloader
1525 ; first byte, init CRC checker
1526 P:1624 54F400 move #$00ffff,a1
00FFFF
1527 P:1626 541300 move a1,x:<rcrcrem
1528 P:1627 00000C rts
1529
1530 ; data bytes, put it to the queue
1531 P:1628 0A024B putb1 bclr #scndb,y:<flags
1532 P:1629 0AF0A8 jcs putb2
001632
1533 P:162B 569000 move x:<rdata,a
1534 P:162C 44F400 move #>$ff,x0
0000FF
1535 P:162E 200046 and x0,a
1536 P:162F 218400 move a1,x0
1537 P:1630 0BF080 jsr putc
00153D
1538
1539 ; discard the previous bit
1540 P:1632 00000C putb2 rts
1541
1542 ; flag detected
1543 P:1633 0A0249 putb3 bclr #hunt,y:<flags
1544 movi #8,x:<rbit
1547 P:1636 0A026A bset #firstb,y:<flags
1548 P:1637 0A026B bset #scndb,y:<flags
1549 P:1638 0AF0A0 jcc putb3a ; reject frame if it is too short
00163D
1550 P:163A 0BF080 jsr rejc
00157D
1551 P:163C 00000C rts
1552
1553 ; calculate the last CRC bit
1554 P:163D 449000 putb3a move x:<rdata,x0
1555 P:163E 45F400 move #>@pow(2,-16),x1 ; shift to right 16 bits
000080
1556 P:1640 2000A0 mpy x0,x1,a
1557 crc x:<rcrcrem
1565
1566 ; check that it is valid
1567 P:164B 44F400 move #>crcchk,x0
00F0B8
1568 P:164D 200043 eor x0,a
1569 P:164E 0AF0A2 jne putb3b ; reject frame if CRC failed
001653
1570 P:1650 0BF080 jsr endc
00156E
1571 P:1652 00000C rts
1572 P:1653 0BF080 putb3b jsr rejc
00157D
1573 P:1655 00000C rts
1574
1575 ; abort detected
1576 P:1656 0A0269 putb4 bset #hunt,y:<flags
1577 P:1657 0BF080 jsr rejc
00157D
1578 P:1659 00000C rts
1579
1580
1581 ;****************************
1582 ;* Request timer *
1583 ;****************************
1584 ; delay in x0 (in 1/baud s)
1585 P:165A 5E8800 stimer move y:<timcnt,a
1586 P:165B 44F440 add x0,a #>$00ffff,x0
00FFFF
1587 P:165D 200046 and x0,a
1588 P:165E 5C0900 move a1,y:<timval
1589 P:165F 0A0264 bset #timer,y:<flags
1590 P:1660 00000C rts
1591
1592
1593 ;****************************
1594 ;* Open codec driver *
1595 ;****************************
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 20
DSP CARD 4 Bootloader
1596 ; Start-up Crystal CS4215 Codec
1597 ; r7 - address of the modulo buffer (x: A/D, y: D/A)
1598 ; m7 - lenght of the modulo buffer
1599 ; x0 - samping rate:
1600 ; 8 kHz $000000
1601 ; 9.6 kHz $003800
1602 ; 16 kHz $000800
1603 ; 27.42857 kHz $001000
1604 ; 32 kHz $001800
1605 ; 48 kHz $003000
1606 ;
1607 ;
1608 ; program SSI to handle Crystal's initial communication mode
1609 P:1661 08F4AC opencd movep #$4f05,x:m_cra ; 16-bit, 16 frames
004F05
1610 P:1663 08F4AD movep #$3b3c,x:m_crb ; generate SCLK and FS
003B3C
1611
1612 P:1665 08F4A1 movep #$01e3,x:m_pcc ; TXD,RXD,SC2,SCK,SRD,STD
0001E3
1613 P:1667 08F4A3 movep #$001c,x:m_pcddr ; SCLK,SC0,SC1 as output
00001C
1614 P:1669 08F4A5 movep #$0000,x:m_pcd ; PDN down (wake up Crystal)
000000
1615
1616 ; send control blocks to the Crystal until we get valid responce from it
1617 P:166B 5C8400 move y:<cryconf,a1 ; add sampling rate info to configuration block
1618 P:166C 60F442 or x0,a #cryconf,r0
000004
1619 P:166E 5C0400 move a1,y:<cryconf
1620 P:166F 0503A0 move #4-1,m0
1621
1622 P:1670 0BF080 wakeCry jsr outblk ; send control info until CLB is low
001734
1623 P:1672 0A06B2 jset #2+16,x:tmpblk+2,wakeCry
001670
1624
1625 ; Crystal is configured, send final control block
1626 P:1674 0A0472 bset #2+16,y:<cryconf+0 ; set CLB high
1627 P:1675 060A80 do #10,confok ; at least two frames after CLB high
001679
1628 P:1677 0BF080 jsr outblk ; and ensure that at least 50 ms elapsed after leaving from PDN state
001734
1629 P:1679 000000 nop
1630 P:167A 05F420 confok move #-1,m0
FFFFFF
1631
1632 ; reset and reprogram SSI again because we will get clock and frame signals from Crystal
1633 P:167C 08F4A1 movep #$0003,x:m_pcc ; SRD,STD
000003
1634 P:167E 08F4AC movep #$4305,x:m_cra ; 16-bit, 4 frames
004305
1635 P:1680 08F4AD movep #$3b0c,x:m_crb ; receive SCLK and FS
003B0C
1636 P:1682 08F4A1 movep #$01e3,x:m_pcc ; TXD,RXD,SC2,SCK,SRD,STD
0001E3
1637
1638 ; then start data transfer and synchronize to it
1639 P:1684 08F4A5 movep #$0010,x:m_pcd ; D/C high (switch Crystal to data mode)
000010
1640
1641 P:1686 0AAE86 waitsyn jclr #m_tde,x:m_sr,waitsyn ; wait for the frame sync
001686
1642 P:1688 0AAEA2 jset #m_tfs,x:m_sr,frmsync
00168E
1643 P:168A 0870AF movep x:m_rx,x:m_tsr
00FFEE
1644 P:168C 0AF080 jmp waitsyn
001686
1645
1646 P:168E 060380 frmsync do #4-1,flshfrm ; then get rid of the remaining data
001693
1647 P:1690 0AAE86 _loop jclr #m_tde,x:m_sr,_loop
001690
1648 P:1692 08DFEF movep y:(r7)+,x:m_tx
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 21
DSP CARD 4 Bootloader
1649 P:1693 0867AF movep x:m_rx,x:(r7)
1650 P:1694 08F4AD flshfrm movep #$7b0c,x:m_crb ; enable transmit interrupts
007B0C
1651
1652 P:1696 00000C rts
1653
1654
1655 ;****************************
1656 ;* Close codec driver *
1657 ;****************************
1658 ; close SSI interface and set codec to power down mode
1659 P:1697 08F4A1 closecd movep #$0003,x:m_pcc ; TXD,RXD
000003
1660 P:1699 08F4A3 movep #$001c,x:m_pcddr ; SCLK,SC0,SC1 as output
00001C
1661 P:169B 08F4A5 movep #$0008,x:m_pcd ; PDN up
000008
1662
1663 P:169D 00000C rts
1664
1665
1666 ;****************************
1667 ;* Update output port *
1668 ;****************************
1669 ; put lowest eight bits in x0 register to general purpose i/o-port
1670 P:169E 0002F8 putio ori #$02,mr ; disable interrupts
1671 P:169F 54F400 move #>$0000ff,a1
0000FF
1672 P:16A1 44F446 and x0,a #>$ffff00,x0
FFFF00
1673 P:16A3 218500 move a1,x1
1674
1675 P:16A4 084E24 movep x:m_pbd,a
1676 P:16A5 200046 and x0,a
1677 P:16A6 200062 or x1,a
1678 P:16A7 08CC24 movep a1,x:m_pbd
1679
1680 P:16A8 00FCB8 andi #$fc,mr
1681 P:16A9 00000C rts
1682
1683 ; *** Persistence routines ***
1684
1685 ; state bits
1686 000000 xstart equ 0
1687 000001 xstop equ 1
1688 000002 xon equ 2
1689 000003 xoff equ 3
1690 000004 xwait equ 4
1691
1692 ; kiss parameters
1693 000001 txdelay equ 1
1694 000002 P equ 2
1695 000003 SlotTim equ 3
1696 000004 TXtail equ 4
1697 000005 FullDup equ 5
1698
1699 P:16AA kisspar dc @cvi(50*baud/100.0) ; txdelay
1700 P:16AB dc @cvi(63*baud/100.0) ; P
1701 P:16AC dc @cvi(10*baud/100.0) ; SlotTim
1702 P:16AD dc @cvi(1*baud/100.0) ; TXtail
1703 P:16AE dc 0 ; FullDup
1704 000005 kisses equ *-kisspar
1705
1706 ;****************************
1707 ;* Carrier off routine *
1708 ;****************************
1709 ; inform Leonid that there are no data transmissions ongoing
1710 P:16AF 0002F8 caroff ori #$02,mr
1711 P:16B0 000000 nop
1712 P:16B1 000000 nop
1713 P:16B2 000000 nop
1714 P:16B3 0A024D bclr #carrier,y:<flags
1715
1716 P:16B4 0A1484 jclr #xwait,x:<pstate,_car1
0016BE
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 22
DSP CARD 4 Bootloader
1717
1718 P:16B6 2C0100 move #(1<<xstart),a1 ; start xmitter
1719 P:16B7 541400 move a1,x:<pstate
1720
1721 P:16B8 6B9400 move y:<xmitsub,r3 ; call XMIT ON
1722 P:16B9 0001F9 ori #$01,ccr
1723 P:16BA 0BE380 jsr (r3)
1724
1725 P:16BB 07F08C move p:kisspar+txdelay-1,a1 ; and set txdelay timer
0016AA
1726 P:16BD 5C1500 move a1,y:<pertim
1727 P:16BE 00FCB8 _car1 andi #$fc,mr
1728 P:16BF 00000C rts
1729
1730
1731 ;****************************
1732 ;* Carrier off routine *
1733 ;****************************
1734 ; inform Leonid that there are no data transmissions ongoing
1735 P:16C0 0A026D caron bset #carrier,y:<flags
1736 P:16C1 00000C rts
1737
1738
1739 ; one KISS frame received
1740 P:16C2 0A14A3 frmrec jset #xoff,x:<pstate,_frm1
0016C7
1741 P:16C4 0A14A1 jset #xstop,x:<pstate,_frm2
0016D5
1742 P:16C6 00000C rts
1743
1744 P:16C7 0A02ED _frm1 jset #carrier,y:<flags,_frm1a ; if no carrier, then start xmitter
0016D2
1745 P:16C9 6B9400 move y:<xmitsub,r3 ; call user's xmit on routine
1746 P:16CA 0001F9 ori #$01,ccr
1747 P:16CB 0BE380 jsr (r3)
1748
1749 P:16CC 2C0100 move #(1<<xstart),a1 ; and change to XSTART state
1750 P:16CD 541400 move a1,x:<pstate
1751
1752 P:16CE 07F08C move p:kisspar+txdelay-1,a1 ; and set txdelay timer
0016AA
1753 P:16D0 5C1500 move a1,y:<pertim
1754 P:16D1 00000C rts
1755
1756 P:16D2 2C1000 _frm1a move #(1<<xwait),a1 ; carrier, wait until it disappears
1757 P:16D3 541400 move a1,x:<pstate
1758 P:16D4 00000C rts
1759
1760 P:16D5 2C0400 _frm2 move #(1<<xon),a1 ; curretly shutting down, but continue directly
1761 P:16D6 541400 move a1,x:<pstate
1762
1763 P:16D7 0A026E bset #givedat,y:<flags
1764 P:16D8 00000C rts
1765
1766 ; trying to read empty buffer
1767 P:16D9 0002F8 rdempty ori #$02,mr
1768 P:16DA 000000 nop
1769 P:16DB 000000 nop
1770 P:16DC 000000 nop
1771 P:16DD 0A1482 jclr #xon,x:<pstate,_rde1
0016E5
1772
1773 P:16DF 2C0200 move #(1<<xstop),a1 ; stop transmitting
1774 P:16E0 541400 move a1,x:<pstate
1775
1776 P:16E1 07F08C move p:kisspar+TXtail-1,a1 ; and set txdelay timer
0016AD
1777 P:16E3 5C1500 move a1,y:<pertim
1778
1779 P:16E4 0A024E bclr #givedat,y:<flags
1780 P:16E5 00FCB8 _rde1 andi #$fc,mr
1781 P:16E6 00000C rts
1782
1783 ; 1/baud s timer ticks here
1784 P:16E7 5C9500 pertick move y:<pertim,a1
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 23
DSP CARD 4 Bootloader
1785 P:16E8 44F400 move #>0,x0
000000
1786 P:16EA 219343 eor x0,a a1,r3
1787 P:16EB 0AF0AA jeq _pert1
0016F6
1788 P:16ED 205300 move (r3)- ; check if timer elapsed
1789 P:16EE 226C00 move r3,a1
1790 P:16EF 6B1543 eor x0,a r3,y:<pertim
1791 P:16F0 0AF0A2 jne _pert1
0016F6
1792 P:16F2 0A14A0 jset #xstart,x:<pstate,_pert2
0016F7
1793 P:16F4 0A14A1 jset #xstop,x:<pstate,_pert3
0016FB
1794 P:16F6 00000C _pert1 rts
1795
1796 P:16F7 2C0400 _pert2 move #(1<<xon),a1 ; start xmitting
1797 P:16F8 541400 move a1,x:<pstate
1798
1799 P:16F9 0A026E bset #givedat,y:<flags ; start giving data to the application program
1800 P:16FA 00000C rts
1801
1802 P:16FB 2C0800 _pert3 move #(1<<xoff),a1 ; stop xmitting
1803 P:16FC 541400 move a1,x:<pstate
1804
1805 P:16FD 6B9400 move y:<xmitsub,r3 ; call user's xmit off
1806 P:16FE 00FEB9 andi #$fe,ccr
1807 P:16FF 0BE380 jsr (r3)
1808 P:1700 00000C rts
1809
1810
1811 ; read one word (updating CRC)
1812 P:1701 0BF080 rdword jsr rdbyte ; MS byte
00170C
1813 P:1703 45F400 move #>@cvi(@pow(2,8-1)),x1
000080
1814 P:1705 2000A0 mpy x0,x1,a
1815 P:1706 580300 move a0,y:<tmp
1816 P:1707 0BF080 jsr rdbyte ; LS byte
00170C
1817 P:1709 5E8300 move y:<tmp,a
1818 P:170A 200042 or x0,a
1819 P:170B 00000C rts
1820
1821 ; wait 1s for the next character and update CRC calculation
1822 P:170C 44F400 rdbyte move #>@cvi(1.0*baud),x0 ; set timer (1s)
002580
1823 P:170E 0BF080 jsr stimer
00165A
1824 P:1710 0BF080 jsr waitchr
001723
1825 crcbyte ; calculate CRC of byte in x0, result in x:<crcrem
1840 P:1721 00000C rts
1841
1842
1843 ; wait for (predetermined time) the next character
1844 P:1722 000086 wchr wait
1845 P:1723 0BF080 waitchr jsr getc ; wait for chr of timer
00157F
1846 P:1725 0AF0A0 jcc chrfnd
001733
1847 P:1727 0A02E4 jset #timer,y:<flags,wchr
001722
1848
1849 P:1729 44F400 sleep move #>@cvi(0.5*baud),x0 ; timer elapsed
0012C0
1850 P:172B 0BF080 jsr stimer ; error condition, blink cmd led
00165A
1851 P:172D 000086 _sleep1 wait
1852 P:172E 0A02E4 jset #timer,y:<flags,_sleep1
00172D
1853 cmdled chg
1855 P:1731 0AF080 jmp sleep
001729
1856
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 24
DSP CARD 4 Bootloader
1857 P:1733 00000C chrfnd rts ; chr found
1858
1859
1860 ; Output one 256 bit block (codec in the first time slot)
1861 P:1734 060480 outblk do #4,outblk1 ; actual data transfer on the first slot only
001739
1862 P:1736 0AAE86 _loop jclr #m_tde,x:m_sr,_loop
001736
1863 P:1738 0860AF movep x:m_rx,x:(r0)
1864 P:1739 08D8EF movep y:(r0)+,x:m_tx
1865
1866 P:173A 060C80 outblk1 do #16-4,outblk2 ; idling remainig slots
00173E
1867 P:173C 0AAE86 _loop jclr #m_tde,x:m_sr,_loop
00173C
1868 P:173E 08CC2E movep a1,x:m_tsr
1869
1870 P:173F 00000C outblk2 rts
1871
1872
1873 ; Calculate program load address (to a1) from the address in a1
1874 ; returns Z if no program in a given slot
1875 P:1740 0603A0 ldadr rep #4-1 ; first calculate directory entry address (16*id+rom)
1876 P:1741 200033 lsl a
1877 P:1742 44F433 lsl a #>rom,x0
008000
1878 P:1744 200040 add x0,a
1879 P:1745 219100 move a1,r1 ; then fetch the load address
1880 P:1746 0BF080 jsr romrdw
001752
1881 P:1748 00000C rts
1882
1883
1884 romhdlr romrdb,romrdw,romload
1940
1941
1942 ; serial buffers
1943 P:1800 inbuf dsm buflen
1944 P:1C00 outbuf dsm buflen
1945
1946
1947 ;****************************
1948 ;* CONTEX STORE FOR INTS *
1949 ;****************************
1950
1951 L:0000 org l:$0000
1952
1953 L:0000 scidata ds 2
1954
1955
1956 X:0002 org x:$0002
1957
1958 X:0002 rhead ds 1
1959 X:0003 rtail ds 1
1960
1961 X:0004 tmpblk dsm 4
1962
1963 X:0008 xhead ds 1
1964 X:0009 xtail ds 1
1965 X:000A seqptr ds 1
1966 X:000B crcrem ds 1
1967
1968 X:000C getkst ds 1
1969 X:000D rnhead ds 1
1970 X:000E xnhead ds 1
1971 X:000F kisscmd ds 1
1972
1973 X:0010 rdata ds 1 ; current byte received
1974 X:0011 rflag ds 1 ; one bit counter
1975 X:0012 rbit ds 1 ; received bit counter
1976 X:0013 rcrcrem ds 1 ; CRC remainder
1977
1978 X:0014 pstate ds 1 ; xmit control module state
1979
1980
Motorola DSP56000 Assembler Version 3.1 94-03-25 12:36:01 boot.asm Page 25
DSP CARD 4 Bootloader
1981 Y:0002 org y:$0002
1982
1983 Y:0002 flags ds 1
1984 Y:0003 tmp ds 1
1985
1986 ; Crystal CS4215 configuration data
1987 ; Stereo, 16-bit linear, XTAL1, 64 bit/frame, generate SCLK and FSYNC
1988 Y:0004 cryconf dc %0000000000000100<<8 ; Control Time Slot 1 & 2
1989 Y:0005 dc %0001001000000000<<8 ; Control Time Slot 3 & 4
1990 Y:0006 dc %0000000000000000<<8 ; Control Time Slot 5 & 6
1991 Y:0007 dc %0000000000000000<<8 ; Control Time Slot 7 & 8
1992
1993 Y:0008 timcnt ds 1
1994 Y:0009 timval ds 1
1995 Y:000A timchg ds 1
1996 Y:000B mspace ds 1
1997 Y:000C pgmptr ds 1
1998
1999 Y:000D khead ds 1
2000 Y:000E kisssub ds 1
2001
2002 Y:000F xstate ds 1 ; current xmitter state
2003 Y:0010 xdata ds 1 ; current byte to be send
2004 Y:0011 x5bit ds 1 ; one bit counter
2005 Y:0012 xbit ds 1 ; send bits counter
2006 Y:0013 xcrcrem ds 1 ; CRC remainder
2007
2008 Y:0014 xmitsub ds 1 ; xmit control module xmit routine address store
2009 Y:0015 pertim ds 1 ; xmit control module timer
2010
2011
2012 end
0 Errors
0 Warnings